﻿myApp.factory('appHttp', function ($http, modalService) {
    function handleError(errorData) {
        var modalOptions = {
            closeButtonText: 'Cancel',
            actionButtonText: 'Ok',
            headerText: 'Error',
            bodyText: 'Data Processing error!'
        };

        modalService.showModal({}, modalOptions);
               
    }
    
    return {
        get: function(url, successCallback) {
            $http.get(url).success(successCallback).error(handleError);
        },
        post: function(url, data, successCallback) {
            $http.post(url, data).success(successCallback).error(handleError);
        }
    }
});